package com.link.base.base.salesbrand.service;

import com.link.base.base.salesbrand.dao.mybatis.mapper.SalesBrandMapper;
import com.link.base.base.salesbrand.model.SalesBrand;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import com.link.core.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author  liushoulong
 * @date 2018-10-29
 * @desc 销售品牌Service
 */
@Service
public class SalesBrandServiceImpl  extends BasicServiceImpl<SalesBrand> implements SalesBrandService {

    @Resource
    private SalesBrandMapper salesBrandMapper;

    @Override
    public BasicMapper<SalesBrand> getBasicMapper() {
        return salesBrandMapper;
    }


    /**
     * 重写 queryById 解析 主要销售渠道
     * @param entity
     * @return SalesBrand
     * @throws Exception
     */
    @Override
    public SalesBrand queryById(SalesBrand entity) throws Exception {
        SalesBrand object = salesBrandMapper.queryById(entity);
        if ( object != null ) {
            if ( StringUtils.isNotBlank(object.getMainDistrChannel())) {
                object.setMainDistrChannelArr(object.getMainDistrChannel().split(","));
            }
        }
        return object;
    }
}
